package com.example.group.network.express_plus_app.viewmodel.factory;

import androidx.annotation.NonNull;
import androidx.lifecycle.ViewModel;
import androidx.lifecycle.ViewModelProvider;


import com.example.group.network.express_plus_app.data.LoginRepository;
import com.example.group.network.express_plus_app.data.RegisterDataSource;
import com.example.group.network.express_plus_app.ui.login.LoginViewModel;
import com.example.group.network.express_plus_app.viewmodel.RegisterViewModel;

/**
 * @author 夏宁
 * @email 1941512303@qq.com
 * @date 2021/3/27 15:44
 */
public class RegisterViewModelFactory implements ViewModelProvider.Factory{
    @NonNull
    @Override
    @SuppressWarnings("unchecked")
    public <T extends ViewModel> T create(@NonNull Class<T> modelClass) {
        RegisterDataSource registerDataSource = new RegisterDataSource();
        if (modelClass.isAssignableFrom(RegisterViewModel.class)) {
            return (T) new RegisterViewModel(registerDataSource);
        } else {
            throw new IllegalArgumentException("Unknown ViewModel class");
        }
    }
}
